var express = require('express');
var router = express.Router();
//引入业务逻辑
var pagePost = require('./pagePost');
var companyDAL=require('./util/dal/companyDAL');
var countryDAL=require('./util/dal/countryDAL');


/* GET home page. */
router.get('/', pagePost.findAll);
//创建内容
router.get('/p',pagePost.insert);
//内容详情
router.get('/p/:pID',pagePost.getById);
//删除内容
router.get('/p/:pID/remove',pagePost.remove);
//修改内容
router.get('/p/:pID/update',pagePost.update);


//mongodb data
router.get('/company', function(req, res) {
  	companyDAL.create({"name":"My Company2"},function(err,result){
      	if(!err){
          	res.send(JSON.stringify(result));
      	}
      	else{
          	res.send(err);
      	}
  	});
});
router.get('/country', function(req, res) {
    countryDAL.create({"name":"My Country2"},function(err,result){
      	if(!err){
          	res.send(JSON.stringify(result));
      	}
      	else{
          	res.send(err);
      	}
  	});
});

module.exports = router;